// pages/usercenter/suggest/index.js
let app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    type: 1,
    content: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  // inputChange(e){
  //   let id = e.currentTarget.id
  //   this.setData({
  //     [id]: e.detail.detail.value
  //   })
  // },
  handleSuggest(){
    let _this = this
    let data = {}
    data.type = this.data.type
    data.content = this.data.content
    app.formPost('/app/suggest/add', data).then(res => {
      _this.setData({
        spinShow: false
      });
      wx.stopPullDownRefresh()
      if (res.code === 0) {
        app.message(res.message, 'success')
        setTimeout(function () {
          wx.switchTab({
            url: '/pages/usercenter/index/index'
          })
        }, 1000)
      } else if (res.code == 999) {
        app.message(res.message, 'error')
      } else if (res.code == -1){
        app.message(res.message, 'error')
      } else {
        app.message(res.message, 'error')
      }
    }).catch(e => {
      _this.setData({
        spinShow: false
      });
      app.message(e, 'error')
    })
  }
})